﻿CKEDITOR.plugins.add('syrinxCode', {
    init: function(a) {
        var b = 'syrinxCode';
        CKEDITOR.dialog.add(b, this.path + 'dialogs/code.js');
        a.addCommand(b, new CKEDITOR.dialogCommand(b));
        a.ui.addButton('SyrinxCode', { label: 'Insert Code Block', command: b });

        if (a.addMenuItems) {
            a.addMenuItems(
				{
				    syrinxCode:
					{
					    label: "Code properties",
					    command: 'syrinxCode',
					    group: 'image'
					}
				});
        }

        if (a.contextMenu) {
            a.contextMenu.addListener(function(element, selection) {
                if (!element || !element.is('textarea'))
                    return null;

                return { syrinxCode: CKEDITOR.TRISTATE_OFF };
            });
        }
    }
});
